﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Qcdz.Domain.Articles;
using Ue.Qcdz.Domain.TreeViews;

namespace Ue.Qcdz.Domain.Medias
{
    public class MediaService
    {
        private static IMediaRepository _repository;

        private static TreeViews.TreeView tagTreeView;

        static MediaService()
        {
            _repository = RepositoryFactory.GetRepository<IMediaRepository, TheMedia>();
            tagTreeView = TreeViewService.Instance.RegisterTreeView(new TreeViews.TreeView(new Guid("7C3B15C2-F783-490F-8319-A973BAE19378"))
            {
                Name = "媒体分类树",
                Description = "媒体分类的树型结构"
            });   
        }
        public static TreeViews.TreeView TagTreeView
        {
            get { return MediaService.tagTreeView; }
        }
        public static TheMedia GetMedia(object mediaKey)
        {
            return MediaService._repository.FindBy(mediaKey);
        }
        public static IList<TheMedia> GetMedia()
        {
            return MediaService._repository.FindAll();
        }
        public static IDataResult<TheMedia> GetMedia(IDataQuery dataQuery)
        {
            return MediaService._repository.FindBy(dataQuery);
        }
        public static void AddMedia(TheMedia permissions)
        {
            MediaService._repository.Add(permissions);
        }
     
        public static void UpdateMedia(TheMedia permissions)
        {
            MediaService._repository[permissions.Key] = permissions;
        }
    }
}
